//
//  BaseTextView.m
//  DreamOf
//
//  Created by 薛小刚 on 2018/8/12.
//  Copyright © 2018年 薛小刚. All rights reserved.
//

#import "BaseTextView.h"

@implementation BaseTextView

- (instancetype)init {
    if (self = [super init]) {
        [self setUpUI];
    }
    return self;
}

//通过xib创建
-(void)awakeFromNib
{
    [super awakeFromNib];
    [self setUpUI];
    
}

- (void)setUpUI
{
    self.keyboardAppearance = UIKeyboardAppearanceDark;

    
    //字体大小
    self.font = [UIFont systemFontOfSize:15];
    
    
    
    //字体颜色
    self.textColor = [UIColor color_text_white];
    //光标颜色
    self.tintColor= self.textColor;
    //占位符的颜色和大小
    [self setValue:[UIColor color_text_deep_gray] forKeyPath:@"_placeholderLabel.textColor"];
    [self setValue:[UIFont boldSystemFontOfSize:15] forKeyPath:@"_placeholderLabel.font"];
    // 不成为第一响应者
    [self resignFirstResponder];
}

- (void)setPlaceholder:(NSString *)placeholder {
    _placeholder = placeholder;
    UILabel * placeLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 50)];
    [placeLabel sizeToFit];
    placeLabel.font = [UIFont systemFontOfSize:15];
    placeLabel.numberOfLines = 1;
    placeLabel.text = _placeholder;
    placeLabel.textColor = [UIColor color_text_deep_gray];
    placeLabel.tag = 100;
    for (UIView * subView in self.subviews) {
        if (subView.tag == 100) {
            return;
        }
    }
    [self addSubview:placeLabel];
    [self setValue:placeLabel forKey:@"_placeholderLabel"];
}


@end
